/*
 * nwpu/2012/2012_3.c
 *
 * Harry Wei <harryxiyou@gmail.com> (C) 2013
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define FILE_NAME	"D:\\test\\a.txt"

int main(int argc, char *argv[]) {
	int i = 0;
	int j = 0;
	int counter = 0;
	FILE *fp = NULL;
	char ch[80];
	int num[26] = {0,};
	char letter = 0;

//	memset((char *) num, 0, 26);
	for (i = 0; i < 26; i++) {
		printf("%d", num[i]);
	}
	printf("\n");
	i = 0;
	fp = fopen(FILE_NAME, "rt");
	if (NULL == fp) {
		fprintf(stderr, "%s\n", "fopen file error!");
		return -1;
	}
	while (!feof(fp) && (4 > i)) {
		printf("999 enter while %d\n", i);
		i += 1;
		memset(ch, '\0', 80);
		fscanf(fp, "%s\n", ch);
		printf("%s\n", ch);
		j = 0;
		while ('\0' != ch[j]) {
			for (letter = 'A', counter = 0; letter <= 'Z'; letter++, counter++) {
				if(letter == ch[j]) {
					printf("letter: %c, counter: %d, ch[%d]: %c\n", letter, counter, j, ch[j]);
					num[counter] += 1;
				}
			}
			j += 1;
		}
	}
	for (i = 0; i < 26; i++) {
		printf("%d ", num[i]);
	}
	printf("\n");
	fclose(fp);
	return 0;
}